<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>弹跳动画效果</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }

        .container {
            text-align: center;
            padding: 20px;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            max-width: 500px;
            width: 100%;
        }

        .demo-area {
            width: 100%;
            height: 200px;
            margin: 20px 0;
            position: relative;
            overflow: hidden;
            background-color: #f9f9f9;
            border-radius: 8px;
        }

        .demo-box {
            width: 100px;
            height: 100px;
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background-color: #00BCD4;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            border-radius: 50%;
        }

        .controls {
            margin-top: 20px;
        }

        button {
            padding: 10px 20px;
            margin: 0 10px;
            border: none;
            border-radius: 4px;
            background-color: #2196F3;
            color: white;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
        }

        button:hover {
            background-color: #0b7dda;
        }

        .bounce {
            animation: bounce 2s infinite;
        }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% { transform: translateY(0) translateX(-50%); }
            40% { transform: translateY(-30px) translateX(-50%); }
            60% { transform: translateY(-15px) translateX(-50%); }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>弹跳动画效果</h1>
        <div class="demo-area">
            <div class="demo-box" id="demoBox">弹跳效果</div>
        </div>
        <div class="controls">
            <button onclick="startBounce()">开始弹跳</button>
            <button onclick="stopBounce()">停止弹跳</button>
        </div>
        <div class="code-section">
            <h3>CSS代码:</h3>
            <pre><code>.bounce {
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-30px); }
  60% { transform: translateY(-15px); }
}</code></pre>
        </div>
    </div>

    <script>
        const box = document.getElementById('demoBox');

        function startBounce() {
            box.classList.add('bounce');
        }

        function stopBounce() {
            box.classList.remove('bounce');
        }
    </script>
</body>
</html>